# from pymysql import Connection
#
# conn = None
# try:
#     # 创建数据库连接
#     conn = Connection(
#         host='localhost',  # 主机地址
#         port=3306,  # 端口
#         user='root',  # 用户名
#         password='root',  # 密码
#         database='learn_pymysql',  # 数据库
#         autocommit=True  # 配置自动提交
#     )
#     # 获取游标
#     cursor = conn.cursor()
#
#     sql = "select * from regions"
#
#     cursor.execute(sql)
#     result = cursor.fetchall()
#     # print(type(result), result)
#     for row in result:
#         print(row)
# except Exception as e:
#     print("发生异常：", e)
# finally:
#     if conn:
#         # 关闭连接
#         conn.close()

from db_tools import query

result = query("select * from regions")
print(result)
